<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>缴费录入</title>
<%@ include file="../au_inc.jsp"%>
<style type="text/css">
table.gridtable {
	font-family: verdana, arial, sans-serif;
	font-size: 11px;
	color: #333333;
	border-width: 1px;
	border-color: #666666;
	border-collapse: collapse;
}

table.gridtable th {
	border-width: 1px;
	padding: 1px;
	border-style: solid;
	border-color: #666666;
	background-color: #dedede;
}

table.gridtable td {
	border-width: 1px;
	padding: 1px;
	border-style: solid;
	border-color: #666666;
	background-color: #ffffff;
}

td input,td select{
	
}
</style>
<script type="text/javascript">
	//所有的子窗体都需要有一个save函数，当点击弹出窗体的保存按钮时所进行的操作
	function btnSave_click() {
		var fun_ret = false;
		var vals = $('#formModule').serialize();
		var url = '${baseUrl}/admin/boothPayLog/doInputPay';
		var valid = $('#formModule').form('validate');

		var pay_img = $("#pay_img")[0].files;
		console.log('pay_img', pay_img);
		//根据ID获得页面当中的form表单元素
		var form = document.querySelector("#formModule");
		//将获得的表单元素作为参数，对formData进行初始化
		var formdata = new FormData(form);
		//通过get方法获得name为advName元素的value值
		
		 if(pay_img.length > 0){
			for(var i=0;i<pay_img.length;i++){
				var file = pay_img[i]
				formdata.append('pay_img_'+i, file, file.name);
				
			}
		}
		 formdata.delete("pay_img")
		console.log(formdata.getAll("pay_img"));//xixi
		
		//通过get方法获得name为advType元素的value值

		var checked = $('#pay_img').val()
		var tip = ''
		if(!checked){
			tip = '缴费凭证不能为空！'
		}
		if(tip){
			$.messager.alert('提示',tip,'error');
			return false;
		}
		
		if (valid) {

			$.ajax({
				async : false,
				url : url,
				type : "post",
				data : formdata,
				cache : false,
				contentType : false,
				processData : false,
				dataType : 'json',
				success : function(data) {
					if (data.success != 0) {
						top.Ext.Msg.alert("提示", data.msg);
					} else {
						fun_ret = true;
					}
				}
			});

		}

		return fun_ret;
	}
</script>
</head>
<body>
	<div style="padding: 0px">
		<form id="formModule" method="post" enctype="multipart/form-data"
			autocomplete="off">
			<input id="payWay" type="hidden" name="boothPayLog.pay_way" value="1"/>
			<input id="boothId" type="hidden" name="boothPayLog.b_id"
				value="${boothId}">
			<input id="applicantId" type="hidden" name="boothPayLog.o_id"
				value="${applicantId}">
			<table cellpadding="0" border="0" width="100%" class="gridtable">
				<tr>
					<th>缴费方式:</th>
					<td colspan="3" style="padding:10px 20px;">
						<span>
							<label style="vertical-align: middle;">支付宝：</label><input style="vertical-align: middle;" type="radio" name="payWay" value="1" checked  onchange="listenPayWay(this)"/>
						</span>
						<span>
							<label style="vertical-align: middle;">微信：</label><input style="vertical-align: middle;" type="radio" name="payWay" value="2" onchange="listenPayWay(this)"/>
						</span>
					</td>
				</tr>
				<tr>
					<th>缴费金额：</th>
					<td><input id="pay_mon" class="easyui-validatebox textbox"
						name="boothPayLog.pay_mon" data-options="required:true,validType:['checkTwoFloat','checkMin[0.01]']"
						value="${boothPayLog.pay_mon }"></input></td>
					<th>类型：</th>
					<td><select class="easyui-combobox" id="pay_type"
						name="boothPayLog.pay_type" style="width: 250px;">
							<option value="1">缴纳租金</option>
							<option value="2">退租</option>
					</select></td>
				</tr>
				<tr>
					<th>缴费凭证:</th>
					<td colspan="3"><input type="file" id="pay_img" class="textbox" style="width:250px;"
						name="pay_img" multiple="multiple"></input></td>
				</tr>
			</table>
		</form>
	</div>
</body>

<script type="text/javascript">
	function listenPayWay(_this){
		var val = $(_this).attr('value');
		$('#payWay').val(val)
		console.log(val)
	}
</script>
</html>
